Skip to content

1. modularize /goal logic - #2184

Open
kevinjosethomas wants to merge 4 commits into
mainfrom
refactor/codebase-cleanup-20260909
Open

1. modularize /goal logic#2184
kevinjosethomas wants to merge 4 commits into
mainfrom
refactor/codebase-cleanup-20260909

Conversation

@kevinjosethomas

@kevinjosethomas kevinjosethomas commented Sep 10, 2026

Copy link
Copy Markdown
Member
  • goal state and accounting now have a dedicated owner, with separate command parsing and persistence modules.
  • first refactor in the cleanup stack; design and rollout are tracked in eng-5938.
  • preserves goal behavior and persistence; all 68 focused tests and npm run check pass.

Note

Medium Risk
Refactors goal accounting and persistence paths that affect continuations and budget limits; behavior is intended to be unchanged but ordering invariants must stay correct.

Overview
Extracts goal lifecycle, persistence, and /goal parsing out of AgentSession into a dedicated goals/ feature folder, as the first step in modularizing session execution code.

GoalController now owns transitions (start/clear/pause/resume/complete/fail), token and wall-clock accounting, continuation increments/rollbacks, assistant usage deduplication, and checkpoint/restore for admission races. createGoalPersistence handles branch load/save, immediate flush, and CLI --goal seed eligibility. parseGoalSlashCommand holds slash parsing and budget validation. AgentSession keeps cross-cutting work—queueing goal context messages, continuations after RLM quiescence, host APIs—and delegates mutations through the controller; shared types stay in core/goals.ts.

Adds src/README.md documenting ownership boundaries and ordering invariants (usage before tools, completion clears stale budget context, continuation rollback restores clock). New test/goals/controller.test.ts and harness updates in goal-continuation-quiescence.test.ts exercise the extracted API.

Reviewed by Cursor Bugbot for commit 7de5766. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Modularize /goal logic into GoalController and goals/commands.ts

  • Extracts goal state ownership, persistence, accounting, and lifecycle transitions from AgentSession into goals/controller.ts and goals/persistence.ts.
  • Moves slash-command parsing and objective validation to goals/commands.ts.
  • Updates AgentSession to delegate goal operations to GoalController instead of using local goal fields.
  • Updates goal-continuation-quiescence.test.ts to use the new controller, and adds controller.test.ts for deterministic lifecycle and accounting tests.
  • Risk: AgentSession.goalState now returns GoalController state instead of locally computed wall-clock state; branch reloads now reload the controller from persistence.

Macroscope summarized 7de5766.

@kevinjosethomas kevinjosethomas added the no-changelog Internal change with no user-visible changelog entry label Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Prime Agent performance — completed

PR 7de57663 compared with main 878410b3.

Overall: 0 regressed · 0 improved · 17 no clear change.

Metric Main This PR Change
Cold startup 2,046.0 ms 1,681.5 ms ≈ -364.6 ms (-17.82%)
Warm startup 1,251.5 ms 1,011.0 ms ≈ -240.5 ms (-19.21%)
Installation 16.13 s 16.17 s ≈ +0.04 s (+0.25%)
Compressed release artifacts 69.98 MB 69.97 MB ≈ -0.01 MB (-0.02%)
Installed footprint 571.97 MB 571.99 MB ≈ +0.02 MB (+0.00%)
Idle memory, summed RSS 1,196.73 MB 1,202.09 MB ≈ +5.36 MB (+0.45%)

Python runtime

Metric Main This PR Change
Python kernel startup 165.0 ms 176.1 ms ≈ +11.1 ms (+6.76%)
Python cell round trip 0.752 ms 0.879 ms ≈ +0.127 ms (+16.93%)
Empty bash command 15.5 ms 16.9 ms ≈ +1.4 ms (+8.85%)
Bash git status 24.8 ms 23.2 ms ≈ -1.6 ms (-6.37%)
Bash 32 KiB output 17.4 ms 17.6 ms ≈ +0.1 ms (+0.68%)
35 cells / 9 shell calls 227.0 ms 234.0 ms ≈ +6.9 ms (+3.05%)
Python interrupt to done 1.888 ms 1.765 ms ≈ -0.123 ms (-6.51%)
Python state snapshot 34.6 ms 34.4 ms ≈ -0.3 ms (-0.79%)
Python state restore 447.2 ms 467.9 ms ≈ +20.7 ms (+4.64%)
Python idle RSS 35.46 MB 33.74 MB ≈ -1.72 MB (-4.85%)
Python RSS after pandas workload 97.62 MB 95.79 MB ≈ -1.83 MB (-1.87%)

Sandbox cost: ~$0.0909 — no inference calls.
Run, logs, and downloadable raw results

Methodology and samples

Main resolved at 2026-09-13T05:39:25.501078+00:00. Harness 878410b3.
Linux x64, 4 vCPU, 8 GB RAM, 20 GB disk; region us.
Image: node:24-bookworm@sha256:be23f54a88d34e8824c741b19b91064094f92c1c97b194144bfc8b50d67258e2.
Stock tools, skills, daemon, and Python bootstrap enabled; fresh homes and a fixed Git fixture.
Onboarding is dismissed; the editor starts without a selected model or submitted prompt.
Medians shown. Arrows require a 20% timing/memory change plus absolute floors and IQR.
These practical noise floors are not a statistical significance test.
Cold means stopped Prime processes; OS filesystem caches are not flushed.
No model requests or credentials. Installation excludes build/setup time.
Installer tarballs use loopback; npm/Python downloads use the network with fresh caches.
Artifact size counts release tarballs; footprint after first use includes registry packages.
MB is decimal. Summed RSS can double-count shared pages; PSS is recorded when available.
Provisioning, setup, and build durations are recorded separately in the raw results.
Kernel probes use the installed JSONL runtime, outside the TUI/TypeScript host.
Per trial: 50 Python cells, 5 calls per shell case, and one 35-cell mix (9 git status calls).
Cell/shell values are batch means; other runtime timings are single operations.
State fixture: a 10,000-row × 8-column integer DataFrame and a 10,000-integer list.
Restore runs in a fresh kernel, including pandas imports; kernel startup is excluded.
Kernel RSS covers the isolated Python process; loaded RSS follows the pandas workload.
Costs estimate full sandbox lifetimes at configured rates, including setup and build.
Budget target: $1; not a billing cap. Performance changes are informational.
Failed or incomplete execution fails the workflow; saved artifacts remain available.
Each side stops a phase after 2 identical consecutive failures.
Skipped trials are not attempted samples. Warm startup requires a successful cold launch.

Metric Main successful/attempted PR successful/attempted Main spread PR spread
Cold startup 10/10 10/10 IQR 288.7 ms IQR 240.7 ms
Warm startup 10/10 10/10 IQR 190.7 ms IQR 125.8 ms
Installation 3/3 3/3 range 0.41 s range 0.17 s
Compressed release artifacts 1/1 1/1
Installed footprint 1/1 1/1
Idle memory, summed RSS 10/10 10/10 IQR 16.46 MB IQR 12.16 MB
Python kernel startup 10/10 10/10 IQR 27.1 ms IQR 14.6 ms
Python cell round trip 10/10 10/10 IQR 0.267 ms IQR 0.123 ms
Empty bash command 10/10 10/10 IQR 3.0 ms IQR 2.0 ms
Bash git status 10/10 10/10 IQR 3.4 ms IQR 1.3 ms
Bash 32 KiB output 10/10 10/10 IQR 4.1 ms IQR 3.2 ms
35 cells / 9 shell calls 10/10 10/10 IQR 29.2 ms IQR 27.2 ms
Python interrupt to done 10/10 10/10 IQR 0.873 ms IQR 0.770 ms
Python state snapshot 10/10 10/10 IQR 11.3 ms IQR 6.2 ms
Python state restore 10/10 10/10 IQR 108.4 ms IQR 23.3 ms
Python idle RSS 10/10 10/10 IQR 3.90 MB IQR 3.72 MB
Python RSS after pandas workload 10/10 10/10 IQR 3.83 MB IQR 4.83 MB

@kevinjosethomas kevinjosethomas changed the title extract goal state and accounting from the session 1. modularize /goal logic Sep 10, 2026
kevinjosethomas added a commit that referenced this pull request Sep 10, 2026
@kevinjosethomas
kevinjosethomas added this pull request to stack #2198 September 10, 2026 08:11
@kevinjosethomas
kevinjosethomas force-pushed the refactor/codebase-cleanup-20260909 branch from caee21d to 120516e Compare September 10, 2026 23:42
@kevinjosethomas
kevinjosethomas force-pushed the refactor/codebase-cleanup-20260909 branch from 120516e to c6135c1 Compare September 11, 2026 19:13

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c6135c1. Configure here.

Comment thread packages/coding-agent/src/goals/controller.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Internal change with no user-visible changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant